﻿//===============================================================================
//	CAskOfferRewardMissionList
//	悬赏任务列表
//===============================================================================

#include "CAskOfferRewardMissionList.h"
#include "../share/user_define.h"


//-------------------------------------------------------------------------------
CAskOfferRewardMissionList::CAskOfferRewardMissionList(uint32_t uid, uint32_t pn)
	: BaseMessage(uid, pn)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
CAskOfferRewardMissionList::~CAskOfferRewardMissionList(void)
{

}

//-------------------------------------------------------------------------------
void CAskOfferRewardMissionList::SetOfferRewardMissionListData(MissionSystem * MissionData,
	uint32_t rewardTimes, uint32_t updateTimes)
{
	_safe_guard_begin;

	_safe_check(MissionData);

	/*临时：屏蔽悬赏任务*/
	//m_jv["ret"] = 1;
	//m_jv["ret"] = 0;

	//Json::Value jv1;
	//Json::Value jv21;
	//jv21.clear();

	//jv1.append(0);	//任务id
	//jv1.append(0);	//任务info_1--当前状态
	//jv1.append(0);	//任务info_2--达成次数

	//jv21.append(jv1);

	//m_jv["misinfo"] = jv21;

	//m_jv["desc"] = "悬赏功能维护中...请见谅.";

	//std::string strTemp = JsonWriter(m_jv);

	//return;
	/*!*/

	uint32_t startIdx = MissionData->GetOfferRewardMissionStartPos();
	uint32_t endIdx = MissionData->GetOfferRewardMissionEndPos();

	Json::Value jv;
	Json::Value jv2;
	jv2.clear();

	for (uint32_t i = startIdx; i <= endIdx; ++i )
	{
		jv.clear();
		mission* p = MissionData->GetMissionInfoByIndex(i);
		_safe_check(p);

		uint32_t idx = i;
		jv.append(idx);//idx
		jv.append(p->m_mission_id);
		jv.append(p->m_scrip_id);
		jv.append(p->m_is_available);
		jv.append(p->m_info.GetValue(0));
		jv.append(p->m_info.GetValue(1));
		jv.append(p->m_info.GetValue(2));
		jv.append(p->m_info.GetValue(3));
		jv.append(p->m_npc_id);
		jv.append(p->m_type);
		jv.append(p->m_star);

		jv2.append(jv);
	}

	m_jv["rtms"] = rewardTimes;
	m_jv["utms"] = updateTimes;

	m_jv["misinfo"] = jv2;
	m_jv["ret"] = 0;

	std::string str = JsonWriter(m_jv);

	_safe_guard_end;
}
